//这个包用于画oled显示界面，便于选择题目
#include "GUI.h"
#include "stdio.h"
#include "string.h"
#include "oled.h"
#include "key.h"

char GUI[30];
extern int modenow;

void menu_show (void)//一般选题界面
{
    int flag = 1;

    while(1)
    {
        if(KEY_Scan() == 2)   //下一项
        {
            delay_ms(10);
            flag++;
            if(flag == 4) 
            {
                flag = 1;
            }
        }

        if(KEY_Scan() == 3) //确认按键
        {
            delay_ms(10);
            OLED_Clear();
            switch (flag)
            {
                case 1: modenow = 1; break;
                case 2: modenow = 2; break;
                case 3: modenow = 3; break;
                case 4: modenow = 4; break;
            }
        }

        switch (flag) 
        {
            case 1:
            {
                sprintf(GUI, "*");
                OLED_ShowString(90, 0, (uint8_t *)GUI, 16);
                sprintf(GUI, " ");
                OLED_ShowString(90, 2, (uint8_t *)GUI, 16);
                OLED_ShowString(90, 4, (uint8_t *)GUI, 16);
                OLED_ShowString(90, 6, (uint8_t *)GUI, 16);
            }break;

            case 2:
            {
                sprintf(GUI, "*");
                OLED_ShowString(90, 2, (uint8_t *)GUI, 16);
                sprintf(GUI, " ");
                OLED_ShowString(90, 0, (uint8_t *)GUI, 16);
                OLED_ShowString(90, 4, (uint8_t *)GUI, 16);
                OLED_ShowString(90, 6, (uint8_t *)GUI, 16);
            }break;

            case 3:
            {
                sprintf(GUI, "*");
                OLED_ShowString(0, 4, (uint8_t *)GUI, 16);
                sprintf(GUI, " ");
                OLED_ShowString(0, 2, (uint8_t *)GUI, 16);
                OLED_ShowString(0, 0, (uint8_t *)GUI, 16);
                OLED_ShowString(0, 6, (uint8_t *)GUI, 16);
            }break;

            case 4:
            {
                sprintf(GUI, "*");
                OLED_ShowString(0, 6, (uint8_t *)GUI, 16);
                sprintf(GUI, " ");
                OLED_ShowString(0, 2, (uint8_t *)GUI, 16);
                OLED_ShowString(0, 4, (uint8_t *)GUI, 16);
                OLED_ShowString(0, 0, (uint8_t *)GUI, 16);
            }break;
        }

    }
}